<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['deliveryChalanList'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['deliveryChalanList'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $fromDate         = date("Y-m-01");
	$challanType      = "";
	$challanTypeId    = "";
	$challanTypeId[0] = "Goods Return Note";
	$challanType[0]   = "Goods Return Note (GRN)";
	
  ///// Select Challan : Start
  $selectChallan = "SELECT DISTINCT challanType
                      FROM deliverychallanmaster
                  ORDER BY challanType"; 
  $selectChallanResult = mysql_query($selectChallan);
  $i = 1;
  while($userRow = mysql_fetch_array($selectChallanResult))
  { 
  	if($userRow['challanType'] == 'Delivery Challan/Note')
	  {
	  	$challanTypeId[$i] = $userRow['challanType'];
	  	$challanType[$i]   = $userRow['challanType']." "."(DCN)";
	  }
    elseif($userRow['challanType'] == 'Goods Inward Note')
    {
    	$challanTypeId[$i] = $userRow['challanType'];
    	$challanType[$i]   = $userRow['challanType']." "."(GIN)";
    }
    elseif($userRow['challanType'] == 'Goods Rejection')
    {
    	$challanTypeId[$i] = $userRow['challanType'];
    	$challanType[$i]   = $userRow['challanType']." "."(GRJ)";
    }
    $i++;
  }
  ///// Select Challan : End
  include("./bottom.php");
  $smarty->assign("challanTypeId",$challanTypeId);
  $smarty->assign("challanType",$challanType);
  $smarty->assign("fromDate",$fromDate);
  $smarty->assign("reportFromDate",date("Y-m-d",strtotime("previous day")));
  $smarty->display("deliveryChalanList.tpl");
}
?>